<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="">
    <input type="text" name="id" v-model="emp.id" readonly>
    <input type="text" name="name" v-model="emp.name">
    <input type="text" name="job" v-model="emp.job">
    <input type="text" name="age" v-model="emp.age">
    <input type="button" value="修改" @click="update()">
</form>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v=new Vue({
        el:"form",
        data:{
            emp:{}
        },
        created:function () {
            let id=location.search.split("=")[1]
            axios.get("/selectById?id="+id).then(function (response) {
                v.emp=response.data
            })
        },
        methods:{
            update:function () {
                let data=new FormData(document.querySelector("form"))
                axios.post("update",data).then(function () {
                    alert("修改成功")
                    location.href="/list.html";

                })
            }
        }
    })
</script>
</body>
</html>